<template>
  <div id="cart">
    <nav-bar class="nav">
      <template slot="center">购物车({{cartLength}})</template>
    </nav-bar>
    <scroll class="cart-content" :pull-up-load="true" ref="scroll">
      <cart-list></cart-list>
    </scroll>
    <cart-bottom-bar></cart-bottom-bar>
  </div>
</template>

<script>
import NavBar from '@/components/common/navbar/NavBar'
import Scroll from '@/components/common/scroll/Scroll'
import CartList from './childCart/CartList.vue'
import CartBottomBar from './childCart/CartBottomBar.vue'

import { mapGetters } from 'vuex'

export default {
  components: {
    NavBar,
    Scroll,
    CartList,
    CartBottomBar,
  },
  computed: {
    // 使用vuex内置方法，将getters里的方法转化为局部计算属性
    ...mapGetters(['cartLength']),
  },
  activated() {
    this.$refs.scroll.refresh()
  },
}
</script>

<style scoped>
#cart {
  height: 100vh;
}
.nav {
  background-color: var(--color-tint);
  color: #fff;
}
.cart-content {
  height: calc(100% - 44px - 55px - 35px);
  overflow: hidden;
}
</style>